<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no,address=no,email=no"/>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>KAA电商管理后台_修改密码</title>
	<script type="text/javascript" src="${path}/js/jquery-2.1.1.min.js"></script>
	<script src="${path}/js/sidebar-menu.js"></script>
	<link href="${path}/css/login.css" rel="stylesheet" media="all">
</head>
<body class="main">
	<h1>KAA电商管理后台</h1>
	<jsp:include page="sidebarNav.jsp"></jsp:include><!-- main_sidebar -->

	<div class="main_con_wrap">
		<div class="main_con modify_adm">
			<form name="modifyadm" method="post" class="messages" id="modifyadm"  action="${path}/updatePassword ">

				<p>
					<span class="title fl">原密码*：</span>
					<input id="oldpassword" name="oldpassword" placeholder="请输入原密码" value="${personnel.password}" readonly="readonly"/><span style="display: inline" id="tip1"></span>
					<span class="clear"></span>
				</p>
				
				<p>
					<span class="title fl">新密码*：</span>
					<input type='password' id="password1" name="password1" placeholder="密码长度必须6-18位" value=""/><span style="display: inline" id="tip2"></span>
					<span class="clear"></span>
				</p>
				
				<p>
					<span class="title fl">确认密码*：</span>
					<input type='password' id="password2" name="password2" placeholder="请确认密码" value=""/><span style="display: inline" id="tip3"></span>
					<span class="clear"></span>
				</p>
				 <div id="tip4"></div>
				<button name="button" class="modifyadm_btn btn" onclick="check()" id="modifyadm_btn">保存</button>
			</form>
		</div><!-- main_con -->
	</div><!-- main_con_wrap -->

	<div class="footer_copyright">
		<p>苏州知行合一网络科技有限公司提供技术支持，版权所有</p>
	</div><!-- footer_copyright -->

<script>
	/////////////////////////侧边栏按钮
	$.sidebarMenu($('.sidebar-menu'))
	/////////////////
             $(document).ready(function(){                
        $("#oldpassword").blur(function(){
                var param=$("#oldpassword").val();
                $.ajax({
                    url:" ",
                    data:{oldpassword:param},                 
                    success:function(e){
                        if(e.code==1){                            
                             $("#tip1").html("<font color=\"green\" size=\"2\"></font>");
                        } 
                        else{                                 
                            /*$("#tip1").html("<font color=\"red\" size=\"2\">  错误</font>");*/
                        }
                    }                 
                });
           });
          $("#password1").blur(function(){
              var num=$("#password1").val().length;
              if(num<6){
                   $("#tip2").html("<font color=\"red\" size=\"2\">密码太短</font>");                
              }
              else if(num>18){
                   $("#tip2").html("<font color=\"red\" size=\"2\">密码太长</font>");                 
              }
              else{
                  $("#tip2").html("<font color=\"green\" size=\"2\"></font>");                
              }
          }) ;
          $("#password2").blur(function(){
              var tmp=$("#password1").val();
              var num=$("#password2").val().length;
              if($("#password2").val()!=tmp){
                  $("#tip3").html("<font color=\"red\" size=\"2\">两次输入密码不一致</font>");                 
              }
              else{
                  if(num>=6&&num<=18){
                      $("#tip3").html("<font color=\"green\" size=\"2\"></font>");                    
                  }                 
                  else{
                      $("#tip3").html("<font color=\"red\" size=\"2\">密码无效</font>");                           
                  }                
              }
          });
              $("#modifyadm_btn").click(function(){
                  var flag=true;
                  var old=$("#oldpassword").val();
                  var pass=$("#password1").val();
                  var pass2=$("#password2").val();
                  var num1=$("#password1").val().length;
                  var num2=$("#password2").val().length;
                  if(num1!=num2||num1<6||num2<6||num1>18||num2>18||pass!=pass2){
                      flag=false;
                  }
                  else{
                      flag=true;
                  }
                  if(flag){                   
                  $.ajax({
                      url:" ",
                      data:{oldpassword:old,password:pass},
                      success:function(e){                         
                          if(e.code==1){
                              $("#tip4").show().html("<font color=\"green\" size=\"3\">  修改成功!</font>");
                              $("#oldpassword").val("");
                              $("#password1").val("");
                              $("#password2").val("");
                              $("#tip1").empty();
                              $("#tip2").empty();
                              $("#tip3").empty();
                              $("#tip4").delay(2000).hide(0);        
                          }
                          else{
                              $("#tip4").show().html("<font color=\"red\" size=\"3\"> 原密码错误</font>");
                          }                                     
                         }
                  });
              }
              else{
                  
                  $("#tip4").show().html("<font color=\"red\" size=\"3\">  请按照提示填写！</font>");
              }
              });                  
        });
</script>
</body>
</html>